﻿@model GAE_PI.Models.DetailActivityModel
@{
    ViewBag.Title = "DetailActivite";
    Layout = "~/Views/Shared/_Layout.cshtml";
    bool isAdmin = GAE_PI.Models.DBModel.getDBM().isAdmin();
    bool isEleve = GAE_PI.Models.DBModel.getDBM().isEleve();
    string etat = GAE_PI.Models.DBModel.getDBM().getCatalogueState();
}
<script id="scriptInit" type="text/javascript">
    $(document).ready(function () {
        $("#wijcarousel0").wijcarousel({
            display: 1,
            showTimer: true,
            showPager: true,
            loop: true,
            pagerType: "dots",
            showContorlsOnHover: false
        });
        $("#supprimerOUI")
			.button()
			.click(function () {
			    $.post('@Url.Action("SupprimerActivite", "SupprimerActivite")', { nomA: '@Model.Nom' });
			    $(location).attr("href", '@Request.Url.AbsoluteUri')
			    //$(location).attr("href", '/SupprimerActivite/SupprimerActivite?nomA=' + $("#supprimerOUI").attr("value"));
			});
    });
</script>
<style type="text/css">
    #wijcarousel0
    {
        width: 750px;
        height: 300px;
    }
</style>
<div id="dialog-form" style="text-align: center" title="Etes-vous sûr de vouloir supprimer cette activité">
    <button id="supprimerOUI" value="@Model.Nom">
        OUI</button>
    <button id="supprimerNON">
        NON</button>
</div>
<h2>@Model.Nom
    @if (Model.Etat.Equals("annule"))
    {
        <text> (annulé)</text>
    }
    else if (Model.Etat.Equals("termine"))
    {
        <text> (terminé)</text>
    }
</h2>
    <div>
        @if (isAdmin && etat.Equals("draft"))
        {
            @Html.ActionLink("Modifier", "ModifierActivite", "ModifierActivite", new { nomA = @Model.Nom }, new { @class = "button" })
            <button id="supprimer">
                Supprimer</button>
        }
    </div>
    <div class="main demo">
        <!-- Begin demo markup -->
        <div>
            <div id="wijcarousel0">
                <ul>
                    @foreach (string item in @Model.Images)
                    {
                        <li>
                            <img src="@item" alt="blu" />
                        </li>
                    }
                </ul>
            </div>
        </div>
    </div>
    <br />
    <br />
    <br />
    <br />
    <br />
    <textarea cols="50" rows="10">
    @Model.Description
</textarea>
    <br />
    <br />
    <table id="listGrid">
        <thead>
            <tr>
                <th>
                    Dates
                </th>
            </tr>
        </thead>
        <tbody>
            @foreach (string date in @Model.Dates)
            {
                <tr>
                    <td>
                        @date
                    </td>
                </tr>
            }
        </tbody>
    </table>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#listGrid").wijgrid({ allowSorting: true, pageSize: 20 });
        });
    </script>
    <br />
    <textarea cols="50" rows="10">
    @Model.Responsables
</textarea>
    <br />
@if (isAdmin)
{
    @Html.Partial("_SelectParticipants", GAE_PI.Models.DBModel.getDBM().getParticipants(Model.Nom))    
}
@if (isEleve && etat.Equals("ouvert"))
{
    if (@Model.InscriptionState == 1)
    {
    @Html.ActionLink("Se désinscrire", "Desinscription", "DetailActivite", new { nomA = @Model.Nom }, new { @class = "button" })
    }
    else if (@Model.InscriptionState == 2)
    {
    @Html.ActionLink("S'inscrire", "Inscription", "DetailActivite", new { nomA = @Model.Nom }, new { @class = "button" })
    }
}
else if (isEleve && (etat.Equals("en cours") || etat.Equals("termine")))
{
    if (@Model.InscriptionState == 1)
    {
    <text>Inscription terminée, vous êtes inscrit</text>
    }
    else if (@Model.InscriptionState == 2)
    {
    <text>Inscription terminée, vous n'êtes pas inscrit</text>
    }
}
